#import "SEGSubmitartificialauthManager.h"

#if __has_include(<Commom/SEGModel.h>)
#import <Commom/SEGModel.h>
#else
#import "SEGModel.h"
#endif
#if __has_include(<Commom/SEGHTTPBusinessManager.h>)
#import <Commom/SEGHTTPBusinessManager.h>
#else
#import "SEGHTTPBusinessManager.h"
#endif

static id _submitArtificialAuthManager;
static dispatch_once_t onceToken;

@implementation SEGSubmitartificialauthManager
#pragma mark - SINGLE----BEGIN----
+(instancetype)sharedManager{
    dispatch_once(&onceToken, ^{
        _submitArtificialAuthManager = [[self alloc] init];
    });
    return _submitArtificialAuthManager;
}

+(void)destroyResource{
    onceToken = 0;
    _submitArtificialAuthManager = nil;
}

#pragma mark - SINGLE----END----

#pragma mark - HTTP----BEGIN----

/// APP端-人工认证-V2
/// @see http://192.168.1.11:9090/html/web/controller/share/share.html#5d70a9e91ec046569d01bbd0
/// @param houseId 房屋ID
/// @param tel 手机号
/// @param name 姓名
/// @param userType 租户类型 : 根据接口来
/// @param inTime 开始时间（yyyy-mm-dd）
/// @param outTime 结束时间（yyyy-mm-dd）
/// @param relId  选填
-(void)requestSubmitartificialauthWithHouseid:(NSString*)houseId tel:(NSString*)tel name:(NSString*)name userType:(NSString*)userType inTime:(NSString*)inTime outTime:(NSString*)outTime relId:(NSString*)relId finished:(void(^)(BOOL isSuccessed,id result,NSString* codeType,NSString* errorMessage))finished{
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setValue:houseId forKey:@"houseId"];
    [params setValue:tel forKey:@"tel"];
    [params setValue:name forKey:@"name"];
    [params setValue:userType forKey:@"userType"];
    [params setValue: (relId && relId.length > 0) ? relId : @"" forKey:@"relId"];
    if(inTime && inTime.length > 0) [params setValue:inTime forKey:@"inTime"];
    if(outTime && outTime.length > 0) [params setValue:outTime forKey:@"outTime"];
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v2/userHouse/submitArtificialAuth",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:params completed:^(BOOL isSuccessed, id result, NSString *codeType, NSError *error) {
        if (!isSuccessed) {
            finished(isSuccessed,nil,codeType,error.localizedDescription);
            return;
        }
        
        self.submitArtificialAuth = [SEGSubmitartificialauthModel yy_modelWithDictionary:result];
        finished(isSuccessed,result,codeType,error.localizedDescription);
        return;
    }];
}
#pragma mark - HTTP----END----

#pragma mark - GETTER----BEGIN----
-(SEGSubmitartificialauthModel *)submitArtificialAuth{
    if (!_submitArtificialAuth) {
        _submitArtificialAuth = [[SEGSubmitartificialauthModel alloc]init];
    }
    return _submitArtificialAuth;
}
#pragma mark - GETTER----END----
@end
